import React from 'react';
import ModalForm from '../../../components/modalForm';
import { requiredRule } from '../../../utils/index';

export default function Editor(props) {
    const { isNew, editorData: { id } } = props;
    let config = {};
    if (!isNew && !id) {
        return;
    }
    if (!isNew) {
        config.id = {
            label: 'ID',
            fd: {
                initialValue: id,
                type: 'hidden'
            },
            input: {
                disabled: true,
            },
        };
    }
    config = {
        ...config,
        name: {
            label: '名称',
            fd: {
                rules: [requiredRule],
            },
        },
        macAddress: {
            label: 'mac地址',
            fd: {
                rules: [requiredRule],
            },
        },
        remark: {
            label: '备注',
            fd: {
                rules: [requiredRule],
            },
        }
    };

    return (
        <ModalForm
            {
                ...{
                    ...props,
                    config,
                }
            }
        />
    );
}
